using MongoDB.Driver;
using MySql.Data.MySqlClient;
using Npgsql;
using Oracle.ManagedDataAccess.Client;
using Renci.SshNet;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Sec_scan系列弱口令检查系统
{/// <summary>
/// 支持以下进行弱口令探测
/// mysql
/// sql server
/// ssh
/// wirndow rdp
/// ftp
/// sockes5
/// oracle
/// postgres
/// mongodb
/// redis
/// </summary>
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            Control.CheckForIllegalCrossThreadCalls = false;
            StartPosition = FormStartPosition.CenterScreen;
        }
        // 延迟请求字段全局
        public int MysqlOns = 0;//mysql 数据库
        public int MsssqlOns = 0;//msssql 数据库
        public int OraclesqlOns = 0;//msssql 数据库
        public int PostsqlOns = 0;//msssql 数据库
        //mysql 数据库全局
        public Thread th;//定义全局线程 该线程仅限于mysql
        public int m = 0;//获取总破解次数
        public int n = 0;//获取错误总数
        public int b = 0;//获取失败总数
        public int MsCount = 0;//破解用时
        //sql server 数据库全局
        public Thread tj;
        public int m1 = 0;//获取总破解次数
        public int n1 = 0;//获取错误总数
        public int b1 = 0;//获取失败总数
        public int MyCount = 0;//msssql数据库破解用时
        //oracle 数据库全局
        public Thread tk;
        public int m2 = 0;//获取总破解次数
        public int n2 = 0;//获取错误总数
        public int b2 = 0;//获取失败总数
        public int OrCount = 0;//破解用时
        //postgres 数据库全局
        public Thread tl;
        public int m3 = 0;//获取总破解次数
        public int n3 = 0;//获取错误总数
        public int b3 = 0;//获取失败总数
        public int PoCount = 0;//破解用时
        //mongodb 数据库全局
        public Thread t2;
        public int m4 = 0;//获取总破解次数
        public int n4 = 0;//获取错误总数
        public int b4 = 0;//获取失败总数
        public int MoCount = 0;//破解用时
        //ssh linux 服务器全局
        public Thread t3;
        public int m5 = 0;//获取总破解次数
        public int n5 = 0;//获取错误总数
        public int b5 = 0;//获取失败总数
        public int LoCount = 0;//破解用时
        //Ftp 服务器全局
        public Thread t4;
        public int m6 = 0;//获取总破解次数
        public int n6 = 0;//获取错误总数
        public int b6 = 0;//获取失败总数
        public int FtCount = 0;//破解用时
        public int secrv = 0;//超时 int 类型转换
        private void Form1_Load(object sender, EventArgs e)
        {
            button3.Enabled = false;
            button4.Enabled = false;
            button7.Enabled = false;
            button10.Enabled = false;
            button13.Enabled = false;
            button16.Enabled = false;
            button21.Enabled = false;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            richTextBox1.Clear();
            if(textBox1.Text == string.Empty)
            {
                MessageBox.Show("IP数据不能为空，请填写");
                return;
            }
            this.timer1.Enabled = true;
            this.timer1.Interval = 1000;
            this.timer1.Start();
            this.timer9.Enabled = true;
            this.timer9.Interval = 1000;
            this.timer9.Start();
            //多线程
            th = new Thread(MysqlCrack);
            th.IsBackground = false;
            th.Start();
        }
        public void MysqlCrack(object obj)
        {
            LogWarning("创建时间：" + DateTime.Now + "   ------   " + "正在创建mysql破解线程" + "\r\n");
            toolStripStatusLabel7.Text = "Y";
            label23.Text = "正在破解";
            button1.Enabled = false;//表示为禁止状态
            button3.Enabled = true;
            //定义密码文件
            string password = @"password\mysql.txt";
            using (StreamReader sr = new StreamReader(password, Encoding.Default))
            {
                string str = sr.ReadToEnd();
                if (!string.IsNullOrEmpty(str))
                {
                    string[] strs = str.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < strs.Length; i++)
                    {
                        try
                        {
                            int swgf = Convert.ToInt32(textBox5.Text);//获取int类型格式
                            MysqlOns = swgf * 1000;
                            System.Threading.Thread.Sleep(Convert.ToInt32(MysqlOns));//设置破解延迟 默认为0
                            MySqlConnectionStringBuilder mysqlcli = new MySqlConnectionStringBuilder();//实例化mysql
                            mysqlcli.Server = textBox1.Text;//破解的IP地址
                            mysqlcli.Port = Convert.ToUInt32(textBox2.Text);//破解的端口
                            mysqlcli.UserID = textBox3.Text;//破解的账号
                            mysqlcli.Password = strs[i];//破解的密码
                            mysqlcli.ConnectionTimeout = Convert.ToUInt32(textBox6.Text);//该类型是uint
                            try
                            {
                                MySqlConnection bs = new MySqlConnection(mysqlcli.ToString());
                                bs.Open();
                                if (bs.State == ConnectionState.Open)
                                {
                                    LogMessages("创建时间：" + DateTime.Now + "   ------   " + "破解成功" + "   " + mysqlcli.Server + "  " + "账号：" + mysqlcli.UserID + "   " + "密码：" + mysqlcli.Password + "\r\n");
                                    th.Abort();
                                    this.timer1.Enabled = false;
                                    this.timer1.Stop();
                                    toolStripStatusLabel5.Text = "0";
                                    this.timer9.Stop();
                                    this.timer9.Enabled = false;
                                    toolStripStatusLabel7.Text = "N";
                                    label23.Text = "破解成功";
                                    button1.Enabled = true;//表示为禁止状态
                                    button3.Enabled = false;
                                    return;
                                }
                                else
                                {
                                    LogError("创建时间：" + DateTime.Now + "   ------   " + "破解失败" + "   " + mysqlcli.Server + "  " + "密码：" + mysqlcli.Password + "\r\n");
                                    n++;
                                    toolStripStatusLabel9.Text = i.ToString();

                                }
                            }
                            catch (Exception)
                            {
                                //内容过多展示的情况下界面会出现卡顿
                                if(richTextBox1.Text.Length > 500000)
                                {
                                    richTextBox1.Clear();
                                }
                                LogError("创建时间：" + DateTime.Now + "   ------   " + "破解失败" + "   ------   " + mysqlcli.Server + "   ------   " + "端口：" + mysqlcli.Port + "   ------   " + "账号：" + mysqlcli.UserID + "   ------   " + "密码：" + mysqlcli.Password + "\r\n");
                                n++;
                                toolStripStatusLabel9.Text = i.ToString();
                            }
                            m++;
                            toolStripStatusLabel3.Text = m.ToString(); //全部请求统计

                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("创建时间：" + DateTime.Now + "   ------   " + "\r\n" + ex);
                            LogError("扫描时间：" + DateTime.Now + "   ------   " + strs[i] + "   ---   " + "状态：错误" + "\r\n");
                            //最后一条由整体错误所引起的错误
                            b++;
                            toolStripStatusLabel11.Text = b.ToString();
                        }
                    }
                    //th.Abort();
                    this.timer1.Enabled = false;
                    this.timer1.Stop();
                    toolStripStatusLabel5.Text = "0";
                    this.timer9.Stop();
                    this.timer9.Enabled = false;
                    toolStripStatusLabel7.Text = "N";
                    label23.Text = "破解结束";
                    button1.Enabled = true;//表示为禁止状态
                    button3.Enabled = false;
                }
            }
        }
        /// <summary>
        /// 对输出颜色进行封装 rictextbox1
        /// </summary>
        /// <param name="color"></param>
        /// <param name="text"></param>
        public delegate void LogAppendDelegate(Color color, string text);
        public void LogAppend(Color color, string text)
        {
            //richTextBox1.AppendText("\r\n");
            richTextBox1.SelectionColor = color;
            richTextBox1.AppendText(text);
        }
        /// red
        public void LogError(string text)
        {
            LogAppendDelegate la = new LogAppendDelegate(LogAppend);
            richTextBox1.Invoke(la, Color.Red, text);
        }
        /// 警告
        public void LogWarning(string text)
        {
            LogAppendDelegate la = new LogAppendDelegate(LogAppend);
            richTextBox1.Invoke(la, Color.Violet, text);
        }
        /// 绿色
        public void LogMessage(string text)
        {
            LogAppendDelegate la = new LogAppendDelegate(LogAppend);
            richTextBox1.Invoke(la, Color.Green, text);
        }
        /// <summary>
        /// 对输出颜色进行封装 rictextbox1
        /// </summary>
        /// <param name="color"></param>
        /// <param name="text"></param>
        public delegate void LogAppendDelegate1(Color color, string text);
        public void LogAppend1(Color color, string text)
        {
            //richTextBox1.AppendText("\r\n");
            richTextBox2.SelectionColor = color;
            richTextBox2.AppendText(text);
        }
        /// 绿色
        public void LogMessages(string text)
        {
            LogAppendDelegate1 la = new LogAppendDelegate1(LogAppend1);
            richTextBox2.Invoke(la, Color.Green, text);
        }
        private void richTextBox1_TextChanged(object sender, EventArgs e)
        {
            if (richTextBox1.Text.Length > 0)
            {
                richTextBox1.SelectionStart = richTextBox1.Text.Length;
                //richTextBox1.SelectionStart = Convert.ToInt32(richTextBox1.Text.Remove(richTextBox1.Text.Length - 1));
                richTextBox1.ScrollToCaret();
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (th != null && th.IsAlive)
            {
                th.Abort();
                this.timer1.Enabled = false;
                this.timer1.Stop();
                toolStripStatusLabel5.Text = "0";
                this.timer9.Stop();
                this.timer9.Enabled = false;
                LogWarning("创建时间：" + DateTime.Now + "   ------   " + "破解线程已终止" + "\r\n");
                toolStripStatusLabel7.Text = "N";
                label23.Text = "破解结束";
                button3.Enabled = false;
                button1.Enabled = true;
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            //获取线程数
            Process myProcess = Process.GetCurrentProcess();//获取该进程
            ProcessThreadCollection PTC = myProcess.Threads;//获取其关联的线程，包括主线程
            int num = PTC.Count;//获取线程数量
            toolStripStatusLabel5.Text = num.ToString();

        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            //toolStripStatusLabel1.Text = System.DateTime.Now.ToString("F");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.StartInfo.UseShellExecute = true;
                p.StartInfo.FileName = "password";
                p.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("打开错误" + ex);
            }
        }
        /// <summary>
        /// sql server 破解
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button6_Click(object sender, EventArgs e)
        {
            richTextBox4.Clear();
            if (textBox12.Text == string.Empty)
            {
                MessageBox.Show("IP数据不能为空，请填写");
                return;
            }
            this.timer3.Enabled = true;
            this.timer3.Interval = 1000;
            this.timer3.Start();
            this.timer8.Enabled = true;
            this.timer8.Interval = 1000;
            this.timer8.Start();
            tj = new Thread(MsssqlCrack);
            tj.IsBackground = false;
            tj.Start();
        }
        public void MsssqlCrack()
        {
            LogWarning2("创建时间：" + DateTime.Now + "   ------   " + "正在创建sql server破解线程" + "\r\n");
            string password = @"password\msssql.txt";
            button6.Enabled = false;
            button4.Enabled = true;
            toolStripStatusLabel14.Text = "Y";
            label22.Text = "正在破解";
            using (StreamReader sr = new StreamReader(password, Encoding.Default))
            {
                string str = sr.ReadToEnd();
                if (!string.IsNullOrEmpty(str))
                {
                    string[] strs = str.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < strs.Length; i++)
                    {
                        try
                        {
                            int swgf = Convert.ToInt32(textBox7.Text);//获取int类型格式
                            MsssqlOns = swgf * 1000;
                            System.Threading.Thread.Sleep(Convert.ToInt32(MsssqlOns));//设置破解延迟 默认为0
                            SqlConnectionStringBuilder msssqlcli = new SqlConnectionStringBuilder();//实例化连接sql server数据库
                            msssqlcli.DataSource = textBox12.Text + "," + (textBox11.Text);//text11是数据库端口
                            msssqlcli.UserID = textBox10.Text;
                            msssqlcli.Password = strs[i];
                            msssqlcli.ConnectTimeout = Convert.ToInt32(textBox8.Text);//超时 以秒为单位
                            try
                            {
                                SqlConnection b = new SqlConnection(msssqlcli.ToString());
                                b.Open();
                                if (b.State == ConnectionState.Open)
                                {
                                    LogMessagess("创建时间：" + DateTime.Now + "   ------   " + "破解成功" + "   " + msssqlcli.DataSource + "  " + "账号：" + msssqlcli.UserID + "   " + "密码：" + strs[i] + "\r\n");
                                    tj.Abort();
                                    this.timer3.Enabled = false;
                                    this.timer3.Stop();
                                    toolStripStatusLabel12.Text = "0";
                                    this.timer8.Stop();
                                    this.timer8.Enabled = false;
                                    toolStripStatusLabel14.Text = "N";
                                    label22.Text = "破解成功";
                                    button6.Enabled = true;
                                    button4.Enabled = false;
                                    return;
                                }
                                else
                                {
                                    MessageBox.Show("数据库连接失败！");
                                }
                            }
                            catch (Exception)
                            {
                                //内容过多展示的情况下界面会出现卡顿
                                if (richTextBox4.Text.Length > 500000)
                                {
                                    richTextBox4.Clear();
                                }
                                LogError2("创建时间：" + DateTime.Now + "   ------   " + "破解失败" + "   ------   " + msssqlcli.DataSource + "   ------   " + "端口：" + textBox11.Text + "   ------   " + "账号：" + msssqlcli.UserID + "   ------   " + "密码：" + msssqlcli.Password + "\r\n");
                                b1++;
                                toolStripStatusLabel16.Text = b1.ToString();
                            }
                            m1++;
                            toolStripStatusLabel11.Text = m1.ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                    }
                    //tj.Abort();
                    this.timer3.Enabled = false;
                    this.timer3.Stop();
                    toolStripStatusLabel12.Text = "0";
                    this.timer8.Stop();
                    this.timer8.Enabled = false;
                    toolStripStatusLabel14.Text = "N";
                    label22.Text = "破解结束";
                    button6.Enabled = true;
                    button4.Enabled = false;
                }
            }
        }
        /// <summary>
        /// 对输出颜色进行封装 rictextbox3
        /// </summary>
        /// <param name="color"></param>
        /// <param name="text"></param>
        public delegate void LogAppendDelegate3(Color color, string text);
        public void LogAppend3(Color color, string text)
        {
            //richTextBox1.AppendText("\r\n");
            richTextBox3.SelectionColor = color;
            richTextBox3.AppendText(text);
        }
        /// 绿色
        public void LogMessagess(string text)
        {
            LogAppendDelegate1 la = new LogAppendDelegate1(LogAppend3);
            richTextBox3.Invoke(la, Color.Green, text);
        }
        /// <summary>
        /// 对输出颜色进行封装 rictextbox4 
        /// </summary>
        /// <param name="color"></param>
        /// <param name="text"></param>
        public delegate void LogAppendDelegate2(Color color, string text);
        public void LogAppend2(Color color, string text)
        {
            //richTextBox1.AppendText("\r\n");
            richTextBox4.SelectionColor = color;
            richTextBox4.AppendText(text);
        }
        /// red
        public void LogError2(string text)
        {
            LogAppendDelegate2 la = new LogAppendDelegate2(LogAppend2);
            richTextBox4.Invoke(la, Color.Red, text);
        }
        /// 警告
        public void LogWarning2(string text)
        {
            LogAppendDelegate2 la = new LogAppendDelegate2(LogAppend2);
            richTextBox4.Invoke(la, Color.Violet, text);
        }
        /// 绿色
        public void LogMessage2(string text)
        {
            LogAppendDelegate2 la = new LogAppendDelegate2(LogAppend2);
            richTextBox4.Invoke(la, Color.Green, text);
        }
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            //检查mysql扫描线程
            if (th != null && th.IsAlive)
            {
                DialogResult Result = MessageBox.Show("请终止扫描线程后进行关闭，强制关闭程序将引发错误", "操作警告", MessageBoxButtons.OKCancel);
                if (Result == DialogResult.Cancel)
                {
                    e.Cancel = true;
                }
            }
            //检查msssql扫描线程
            if (tj != null && tj.IsAlive)
            {
                DialogResult Result = MessageBox.Show("请终止扫描线程后进行关闭，强制关闭程序将引发错误", "操作警告", MessageBoxButtons.OKCancel);
                if (Result == DialogResult.Cancel)
                {
                    e.Cancel = true;
                }
            }
            //检查oracle扫描线程
            if (tk != null && tk.IsAlive)
            {
                DialogResult Result = MessageBox.Show("请终止扫描线程后进行关闭，强制关闭程序将引发错误", "操作警告", MessageBoxButtons.OKCancel);
                if (Result == DialogResult.Cancel)
                {
                    e.Cancel = true;
                }
            }
            //检查postgres扫描线程
            if (tl != null && tl.IsAlive)
            {
                DialogResult Result = MessageBox.Show("请终止扫描线程后进行关闭，强制关闭程序将引发错误", "操作警告", MessageBoxButtons.OKCancel);
                if (Result == DialogResult.Cancel)
                {
                    e.Cancel = true;
                }
            }
            //检查mongodb扫描线程
            if (t2 != null && t2.IsAlive)
            {
                DialogResult Result = MessageBox.Show("请终止扫描线程后进行关闭，强制关闭程序将引发错误", "操作警告", MessageBoxButtons.OKCancel);
                if (Result == DialogResult.Cancel)
                {
                    e.Cancel = true;
                }
            }
            //检查linux扫描线程
            if (t3 != null && t3.IsAlive)
            {
                DialogResult Result = MessageBox.Show("请终止扫描线程后进行关闭，强制关闭程序将引发错误", "操作警告", MessageBoxButtons.OKCancel);
                if (Result == DialogResult.Cancel)
                {
                    e.Cancel = true;
                }
            }
            //检查FTP扫描线程
            if (t4 != null && t4.IsAlive)
            {
                DialogResult Result = MessageBox.Show("请终止扫描线程后进行关闭，强制关闭程序将引发错误", "操作警告", MessageBoxButtons.OKCancel);
                if (Result == DialogResult.Cancel)
                {
                    e.Cancel = true;
                }
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (tj != null && tj.IsAlive)
            {
                tj.Abort();
                this.timer3.Enabled = false;
                this.timer3.Stop();
                toolStripStatusLabel12.Text = "0";
                this.timer8.Stop();
                this.timer8.Enabled = false;
                LogWarning2("创建时间：" + DateTime.Now + "   ------   " + "线程终止" + "\r\n");
                button6.Enabled = true;
                button4.Enabled = false;
                toolStripStatusLabel14.Text = "N";
                label22.Text = "破解结束";
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.StartInfo.UseShellExecute = true;
                p.StartInfo.FileName = "password";
                p.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("打开错误" + ex);
            }
        }

        private void richTextBox4_TextChanged(object sender, EventArgs e)
        {
            if (richTextBox4.Text.Length > 0)
            {
                richTextBox4.SelectionStart = richTextBox4.Text.Length;
                //richTextBox1.SelectionStart = Convert.ToInt32(richTextBox1.Text.Remove(richTextBox1.Text.Length - 1));
                richTextBox4.ScrollToCaret();
            }
        }

        private void timer3_Tick(object sender, EventArgs e)
        {
            Process myProcess = Process.GetCurrentProcess();//获取该进程
            ProcessThreadCollection PTC = myProcess.Threads;//获取其关联的线程，包括主线程
            int num = PTC.Count;//获取线程数量
            toolStripStatusLabel12.Text = num.ToString();
        }
        /// <summary>
        /// 创建oracle 数据库连接
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button9_Click(object sender, EventArgs e)
        {
            richTextBox6.Clear();
            if (textBox18.Text == string.Empty)
            {
                MessageBox.Show("IP数据不能为空，请填写");
                return;
            }
            this.timer4.Enabled = true;
            this.timer4.Interval = 1000;
            this.timer4.Start();
            this.timer10.Enabled = true;
            this.timer10.Interval = 1000;
            this.timer10.Start();
            tk = new Thread(OracleCrack);
            tk.IsBackground = false;
            tk.Start();
        }
        public void OracleCrack()
        {
            LogWarning6("创建时间：" + DateTime.Now + "   ------   " + "正在创建oracle破解线程" + "\r\n");
            string password = @"password\oracle.txt";
            button9.Enabled = false;
            button7.Enabled = true;
            toolStripStatusLabel24.Text = "Y";
            label25.Text = "正在破解";
            using (StreamReader sr = new StreamReader(password, Encoding.Default))
            {
                string str = sr.ReadToEnd();
                if (!string.IsNullOrEmpty(str))
                {
                    string[] strs = str.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < strs.Length; i++)
                    {
                        try
                        {
                            int swgf = Convert.ToInt32(textBox13.Text);//获取int类型格式
                            OraclesqlOns = swgf * 1000;
                            System.Threading.Thread.Sleep(Convert.ToInt32(OraclesqlOns));//设置破解延迟 默认为0
                            OracleConnectionStringBuilder s1 = new OracleConnectionStringBuilder();
                            s1.DataSource = textBox18.Text + ":" + Convert.ToInt32(textBox17.Text) + "/" + textBox37.Text;//ip 加 端口
                            s1.UserID = textBox16.Text;
                            s1.Password = strs[i];
                            s1.ConnectionTimeout = Convert.ToInt32(textBox14.Text);//超时
                            try
                            {
                                System.Threading.Thread.Sleep(Convert.ToInt32(textBox13.Text));//延迟
                                OracleConnection conn = new OracleConnection(s1.ToString());
                                conn.Open();
                                if (conn.State == ConnectionState.Open)
                                {
                                    LogMessage5("创建时间：" + DateTime.Now + "   ------   " + "破解成功" + "   " + s1.DataSource + "  " + "账号：" + s1.UserID + "   " + "密码：" + strs[i] + "\r\n");
                                    tk.Abort();
                                    this.timer4.Enabled = false;
                                    this.timer4.Stop();
                                    toolStripStatusLabel22.Text = "0";
                                    this.timer10.Stop();
                                    this.timer10.Enabled = false;
                                    toolStripStatusLabel14.Text = "N";
                                    label22.Text = "破解成功";
                                    button9.Enabled = true;
                                    button7.Enabled = false;
                                }
                                else
                                {
                                    LogError6("创建时间：" + DateTime.Now + "   ------   " + "破解失败" + "   ------   " + s1.DataSource + "   ------   " + "端口：" + textBox17.Text + "   ------   " + "账号：" + s1.UserID + "   ------   " + "密码：" + s1.Password + "\r\n");
                                    n2++;
                                }
                            }

                            catch (Exception ex)
                            {
                                //内容过多展示的情况下界面会出现卡顿
                                if (richTextBox6.Text.Length > 500000)
                                {
                                    richTextBox6.Clear();
                                }
                                Console.WriteLine(ex);
                                LogError6("创建时间：" + DateTime.Now + "   ------   " + "破解失败" + "   ------   " + s1.DataSource + "   ------   " + "端口：" + textBox17.Text + "   ------   " + "账号：" + s1.UserID + "   ------   " + "密码：" + s1.Password + "\r\n");
                                b2++;
                                toolStripStatusLabel26.Text = b2.ToString();
                            }
                            m2++;
                            toolStripStatusLabel20.Text = m2.ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                    }
                    //tk.Abort();
                    this.timer4.Enabled = false;
                    this.timer4.Stop();
                    toolStripStatusLabel22.Text = "0";
                    this.timer10.Stop();
                    this.timer10.Enabled = false;
                    toolStripStatusLabel14.Text = "N";
                    label22.Text = "破解结束";
                    button9.Enabled = true;
                    button7.Enabled = false;
                }
            }
        }
        /// <summary>
        /// 对输出颜色进行封装 rictextbox5 
        /// </summary>
        /// <param name="color"></param>
        /// <param name="text"></param>
        public delegate void LogAppendDelegate6(Color color, string text);
        public void LogAppend6(Color color, string text)
        {
            //richTextBox1.AppendText("\r\n");
            richTextBox6.SelectionColor = color;
            richTextBox6.AppendText(text);
        }
        /// red
        public void LogError6(string text)
        {
            LogAppendDelegate6 la = new LogAppendDelegate6(LogAppend6);
            richTextBox6.Invoke(la, Color.Red, text);
        }
        /// 警告
        public void LogWarning6(string text)
        {
            LogAppendDelegate6 la = new LogAppendDelegate6(LogAppend6);
            richTextBox6.Invoke(la, Color.Violet, text);
        }
        /// 绿色
        public void LogMessage6(string text)
        {
            LogAppendDelegate6 la = new LogAppendDelegate6(LogAppend6);
            richTextBox6.Invoke(la, Color.Green, text);
        }
        /// <summary>
        /// 对输出颜色进行封装 rictextbox5 
        /// </summary>
        /// <param name="color"></param>
        /// <param name="text"></param>
        public delegate void LogAppendDelegate5(Color color, string text);
        public void LogAppend5(Color color, string text)
        {
            //richTextBox1.AppendText("\r\n");
            richTextBox5.SelectionColor = color;
            richTextBox5.AppendText(text);
        }
        /// red
        public void LogError5(string text)
        {
            LogAppendDelegate5 la = new LogAppendDelegate5(LogAppend5);
            richTextBox5.Invoke(la, Color.Green, text);
        }
        public void LogMessage5(string text)
        {
            LogAppendDelegate5 la = new LogAppendDelegate5(LogAppend5);
            richTextBox5.Invoke(la, Color.Green, text);
        }
        private void richTextBox6_TextChanged(object sender, EventArgs e)
        {
            if (richTextBox6.Text.Length > 0)
            {
                richTextBox6.SelectionStart = richTextBox6.Text.Length;
                //richTextBox1.SelectionStart = Convert.ToInt32(richTextBox1.Text.Remove(richTextBox1.Text.Length - 1));
                richTextBox6.ScrollToCaret();
            }
        }

        private void button7_Click(object sender, EventArgs e)
        {
            if (tk != null && tk.IsAlive)
            {
                tk.Abort();
                this.timer4.Enabled = false;
                this.timer4.Stop();
                toolStripStatusLabel22.Text = "0";
                this.timer10.Stop();
                this.timer10.Enabled = false;
                LogWarning6("创建时间：" + DateTime.Now + "   ------   " + "线程终止" + "\r\n");
                button9.Enabled = true;
                button7.Enabled = false;
                toolStripStatusLabel24.Text = "N";
                label25.Text = "破解结束";
            }
        }

        private void timer4_Tick(object sender, EventArgs e)
        {
            Process myProcess = Process.GetCurrentProcess();//获取该进程
            ProcessThreadCollection PTC = myProcess.Threads;//获取其关联的线程，包括主线程
            int num = PTC.Count;//获取线程数量
            toolStripStatusLabel22.Text = num.ToString();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            try
            {
                System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.StartInfo.UseShellExecute = true;
                p.StartInfo.FileName = "password";
                p.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("打开错误" + ex);
            }
        }
        /// <summary>
        /// postgres 数据库破解
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button12_Click(object sender, EventArgs e)
        {
            richTextBox7.Clear();
            if (textBox24.Text == string.Empty)
            {
                MessageBox.Show("IP数据不能为空，请填写");
                return;
            }
            this.timer5.Enabled = true;
            this.timer5.Interval = 1000;
            this.timer5.Start();
            this.timer11.Enabled = true;
            this.timer11.Interval = 1000;
            this.timer11.Start();
            tl = new Thread(PostgresCrack);
            tl.IsBackground = false;
            tl.Start();
        }
        public void PostgresCrack()
        {
            LogWarning7("创建时间：" + DateTime.Now + "   ------   " + "正在创建postgres破解线程" + "\r\n");
            string password = @"password\postgres.txt";
            button12.Enabled = false;
            button10.Enabled = true;
            toolStripStatusLabel33.Text = "Y";
            label37.Text = "正在破解";
            using (StreamReader sr = new StreamReader(password, Encoding.Default))
            {
                string str = sr.ReadToEnd();
                if (!string.IsNullOrEmpty(str))
                {
                    string[] strs = str.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < strs.Length; i++)
                    {
                        try
                        {
                            int swgf = Convert.ToInt32(textBox19.Text);//获取int类型格式
                            PostsqlOns = swgf * 1000;
                            System.Threading.Thread.Sleep(Convert.ToInt32(PostsqlOns));//设置破解延迟 默认为0
                            NpgsqlConnectionStringBuilder s2 = new NpgsqlConnectionStringBuilder();
                            s2.Host = textBox24.Text;//IP地址
                            s2.Port = Convert.ToInt32(textBox23.Text);
                            s2.Username = textBox22.Text;
                            s2.Password = strs[i];
                            try
                            {
                                System.Threading.Thread.Sleep(Convert.ToInt32(textBox19.Text));
                                NpgsqlConnection conn = new NpgsqlConnection(s2.ToString());
                                conn.Open();
                                if (conn.State == ConnectionState.Open)
                                {
                                    LogMessage8("创建时间：" + DateTime.Now + "   ------   " + "破解成功" + "   " + s2.Host + "  " + "账号：" + s2.Username + "   " + "密码：" + strs[i] + "\r\n");
                                    tl.Abort();
                                    this.timer5.Enabled = false;
                                    this.timer5.Stop();
                                    toolStripStatusLabel31.Text = "0";
                                    this.timer11.Stop();
                                    this.timer11.Enabled = false;
                                    toolStripStatusLabel33.Text = "N";
                                    label49.Text = "破解成功";
                                    button12.Enabled = true;
                                    button10.Enabled = false;
                                    return;
                                }
                                else
                                {
                                    LogError7("创建时间：" + DateTime.Now + "   ------   " + "破解失败" + "   " + s2.Host + "  " + "账号：" + s2.Username + "   " + "密码：" + strs[i] + "\r\n");
                                    n3++;
                                }
                            }

                            catch (Exception ex)
                            {
                                //内容过多展示的情况下界面会出现卡顿
                                if (richTextBox7.Text.Length > 500000)
                                {
                                    richTextBox7.Clear();
                                }
                                Console.WriteLine(ex);
                                LogError7("创建时间：" + DateTime.Now + "   ------   " + "破解失败" + "   ------   " + s2.Host + "   ------   " + "端口：" + s2.Port + "   ------   " + "账号：" + s2.Username + "   ------   " + "密码：" + s2.Password + "\r\n");
                                b3++;
                                toolStripStatusLabel35.Text = b3.ToString();
                            }
                            m3++;
                            toolStripStatusLabel29.Text = m3.ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                    }
                    //tl.Abort();
                    this.timer5.Enabled = false;
                    this.timer5.Stop();
                    toolStripStatusLabel31.Text = "0";
                    this.timer11.Stop();
                    this.timer11.Enabled = false;
                    toolStripStatusLabel33.Text = "N";
                    label49.Text = "破解结束";
                    button12.Enabled = true;
                    button10.Enabled = false;
                }
            }
        }
        /// <summary>
        /// 对输出颜色进行封装 rictextbox7 
        /// </summary>
        /// <param name="color"></param>
        /// <param name="text"></param>
        public delegate void LogAppendDelegate7(Color color, string text);
        public void LogAppend7(Color color, string text)
        {
            //richTextBox1.AppendText("\r\n");
            richTextBox7.SelectionColor = color;
            richTextBox7.AppendText(text);
        }
        /// red
        public void LogError7(string text)
        {
            LogAppendDelegate7 la = new LogAppendDelegate7(LogAppend7);
            richTextBox7.Invoke(la, Color.Red, text);
        }
        public void LogWarning7(string text)
        {
            LogAppendDelegate7 la = new LogAppendDelegate7(LogAppend7);
            richTextBox7.Invoke(la, Color.Violet, text);
        }
        /// 绿色
        public void LogMessage7(string text)
        {
            LogAppendDelegate7 la = new LogAppendDelegate7(LogAppend7);
            richTextBox7.Invoke(la, Color.Green, text);
        }
        /// <summary>
        /// 对输出颜色进行封装 rictextbox8 
        /// </summary>
        /// <param name="color"></param>
        /// <param name="text"></param>
        public delegate void LogAppendDelegate8(Color color, string text);
        public void LogAppend8(Color color, string text)
        {
            //richTextBox1.AppendText("\r\n");
            richTextBox8.SelectionColor = color;
            richTextBox8.AppendText(text);
        }
        /// 绿色
        public void LogMessage8(string text)
        {
            LogAppendDelegate8 la = new LogAppendDelegate8(LogAppend8);
            richTextBox8.Invoke(la, Color.Green, text);
        }

        private void richTextBox7_TextChanged(object sender, EventArgs e)
        {
            if (richTextBox7.Text.Length > 0)
            {
                richTextBox7.SelectionStart = richTextBox7.Text.Length;
                //richTextBox1.SelectionStart = Convert.ToInt32(richTextBox1.Text.Remove(richTextBox1.Text.Length - 1));
                richTextBox7.ScrollToCaret();
            }
        }

        private void timer5_Tick(object sender, EventArgs e)
        {
            Process myProcess = Process.GetCurrentProcess();//获取该进程
            ProcessThreadCollection PTC = myProcess.Threads;//获取其关联的线程，包括主线程
            int num = PTC.Count;//获取线程数量
            toolStripStatusLabel31.Text = num.ToString();
        }

        private void button10_Click(object sender, EventArgs e)
        {
            if (tl != null && tl.IsAlive)
            {
                tl.Abort();
                this.timer5.Enabled = false;
                this.timer5.Stop();
                toolStripStatusLabel31.Text = "0";
                this.timer11.Stop();
                this.timer11.Enabled = false;
                toolStripStatusLabel33.Text = "N";
                label37.Text = "破解结束";
                button12.Enabled = true;
                button10.Enabled = false;
                LogWarning7("创建时间：" + DateTime.Now + "   ------   " + "破解终止" + "\r\n");
            }
        }
        /// <summary>
        /// mongodb 数据库破解
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button15_Click(object sender, EventArgs e)
        {
            richTextBox10.Clear();
            if (textBox30.Text == string.Empty)
            {
                MessageBox.Show("IP数据不能为空，请填写");
                return;
            }
            this.timer6.Enabled = true;
            this.timer6.Interval = 1000;
            this.timer6.Start();
            this.timer12.Enabled = true;
            this.timer12.Interval = 1000;
            this.timer12.Start();
            t2 = new Thread(MongoCrack);
            t2.IsBackground = false;
            t2.Start();

        }
        public void MongoCrack()
        {
            //bool flag = true; // 通过验证
            LogWarning10("创建时间：" + DateTime.Now + "   ------   " + "正在创建mongodb破解线程" + "\r\n");
            string password = @"password\mongodb.txt";
            button15.Enabled = true;
            button13.Enabled = false;
            label65.Text = "Y";
            label49.Text = "正在破解";
            using (StreamReader sr = new StreamReader(password, Encoding.Default))
            {
                string str = sr.ReadToEnd();
                if (!string.IsNullOrEmpty(str))
                {
                    string[] strs = str.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < strs.Length; i++)
                    {
                        try
                        {
                            System.Threading.Thread.Sleep(Convert.ToInt32(textBox25.Text));//访问延迟
                            //int swgf = Convert.ToInt32(textBox19.Text);//获取int类型格式
                            //PostsqlOns = swgf * 1000;
                            //System.Threading.Thread.Sleep(Convert.ToInt32(PostsqlOns));//设置破解延迟 默认为0
                            string ss = "mongodb://" + textBox28.Text + ":" + strs[i] + "@" + textBox30.Text + ":" + textBox29.Text + "/" + textBox38.Text;
                            MongoUrl mongourl = new MongoUrl(ss);
                            MongoClientSettings settings = MongoClientSettings.FromUrl(mongourl);
                            settings.ServerSelectionTimeout = new TimeSpan(0, 0, Convert.ToInt32(textBox25.Text)); // 设置寻找服务器的时间
                            MongoClient server = new MongoClient(settings); //创建数据库连接 
                            //server.ListDatabaseNames(); // 打开数据库
                            server.ListDatabaseNames();
                            var s1 = server.ToString();
                            if (s1.Length >= 1)
                            {
                                LogMessage9("创建时间：" + DateTime.Now + "   ------   " + "破解成功" + "   " + textBox30.Text + "  " + "账号：" + textBox28.Text + "   " + "密码：" + strs[i] + "\r\n");
                                // strs i 指密码 | 28 账号 | 30 破解地址 | 29 端口 | 38 数据库
                                t2.Abort();
                                this.timer12.Stop();
                                this.timer12.Enabled = false;
                                this.timer6.Enabled = false;
                                this.timer6.Stop();
                                label63.Text = "0";
                                toolStripStatusLabel33.Text = "N";
                                label37.Text = "破解成功";
                                button15.Enabled = true;
                                button13.Enabled = false;
                                return;
                            }
                            else
                            {
                                //内容过多展示的情况下界面会出现卡顿
                                if (richTextBox10.Text.Length > 500000)
                                {
                                    richTextBox10.Clear();
                                }
                                LogError10("创建时间：" + DateTime.Now + "   ------   " + "破解失败" + "   " + textBox30.Text + "  " + "账号：" + textBox28.Text + "   " + "密码：" + strs[i] + "\r\n");
                            }
                            m4++;
                            label62.Text = m4.ToString();
                        }
                        catch (Exception ex)
                        {
                            //flag = false;
                            LogError10("创建时间：" + DateTime.Now + "   ------   " + "破解失败" + "   " + textBox30.Text + "  " + "账号：" + textBox28.Text + "   " + "密码：" + strs[i] + "\r\n");
                            Console.WriteLine(ex);
                            b4++;
                            label67.Text = b4.ToString();
                        }
                    }
                    this.timer6.Enabled = false;
                    this.timer6.Stop();
                    label63.Text = "0";
                    this.timer12.Stop();
                    this.timer12.Enabled = false;
                    toolStripStatusLabel33.Text = "N";
                    label37.Text = "破解结束";
                    button15.Enabled = true;
                    button13.Enabled = false;
                }
            }
        }
        /// <summary>
        /// 对输出颜色进行封装 rictextbox10 
        /// </summary>
        /// <param name="color"></param>
        /// <param name="text"></param>
        public delegate void LogAppendDelegate10(Color color, string text);
        public void LogAppend10(Color color, string text)
        {
            //richTextBox1.AppendText("\r\n");
            richTextBox10.SelectionColor = color;
            richTextBox10.AppendText(text);
        }
        /// red
        public void LogError10(string text)
        {
            LogAppendDelegate10 la = new LogAppendDelegate10(LogAppend10);
            richTextBox10.Invoke(la, Color.Red, text);
        }
        public void LogWarning10(string text)
        {
            LogAppendDelegate10 la = new LogAppendDelegate10(LogAppend10);
            richTextBox10.Invoke(la, Color.Violet, text);
        }
        /// 绿色
        public void LogMessage10(string text)
        {
            LogAppendDelegate10 la = new LogAppendDelegate10(LogAppend10);
            richTextBox10.Invoke(la, Color.Green, text);
        }
        private void button18_Click(object sender, EventArgs e)
        {

        }
        /// <summary>
        /// 对输出颜色进行封装 rictextbo9 
        /// </summary>
        /// <param name="color"></param>
        /// <param name="text"></param>
        public delegate void LogAppendDelegate9(Color color, string text);
        public void LogAppend9(Color color, string text)
        {
            //richTextBox1.AppendText("\r\n");
            richTextBox9.SelectionColor = color;
            richTextBox9.AppendText(text);
        }
        /// 绿色
        public void LogMessage9(string text)
        {
            LogAppendDelegate9 la = new LogAppendDelegate9(LogAppend9);
            richTextBox9.Invoke(la, Color.Green, text);
        }
        private void button19_Click(object sender, EventArgs e)
        {
            //验证是否存在未授权访问 30.text 服务器地址 ： 29text 端口
            //测试地址：5.199.168.129
            try
            {
                string connectionString = "mongodb://" + textBox30.Text + ":" + textBox29.Text;
                MongoClient s1 = new MongoClient(connectionString);
                s1.ListDatabaseNames();
                var s2 = s1.ToString();
                if(s2.Length >= 1)
                {
                    MessageBox.Show("该资产存在未授权访问！");
                    return;
                }
                else
                {
                    MessageBox.Show("该资产不存在未授权访问！");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("验证错误：不存在未授权访问" + "\r\n" + ex);
            }
        }

        private void timer6_Tick(object sender, EventArgs e)
        {
            Process myProcess = Process.GetCurrentProcess();//获取该进程
            ProcessThreadCollection PTC = myProcess.Threads;//获取其关联的线程，包括主线程
            int num = PTC.Count;//获取线程数量
            label63.Text = num.ToString();
        }

        private void button13_Click(object sender, EventArgs e)
        {
            if (t2 != null && t2.IsAlive)
            {
                t2.Abort();
                this.timer6.Enabled = false;
                this.timer6.Stop();
                label63.Text = "0";
                this.timer12.Stop();
                this.timer12.Enabled = false;
                label65.Text = "N";
                label49.Text = "破解结束";
                button15.Enabled = true;
                button13.Enabled = false;
                LogWarning10("创建时间：" + DateTime.Now + "   ------   " + "破解终止" + "\r\n");
            }
        }

        private void richTextBox10_TextChanged(object sender, EventArgs e)
        {
            //进行自动换行
            if (richTextBox10.Text.Length > 0)
            {
                richTextBox10.SelectionStart = richTextBox10.Text.Length;
                //richTextBox1.SelectionStart = Convert.ToInt32(richTextBox1.Text.Remove(richTextBox1.Text.Length - 1));
                richTextBox10.ScrollToCaret();
            }
        }

        private void button11_Click(object sender, EventArgs e)
        {
            try
            {
                System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.StartInfo.UseShellExecute = true;
                p.StartInfo.FileName = "password";
                p.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("打开错误" + ex);
            }
        }

        private void button14_Click(object sender, EventArgs e)
        {
            try
            {
                System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.StartInfo.UseShellExecute = true;
                p.StartInfo.FileName = "password";
                p.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("打开错误" + ex);
            }
        }
        /// <summary>
        /// ssh 服务器破解
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button23_Click(object sender, EventArgs e)
        {
            richTextBox12.Clear();
            if (textBox45.Text == string.Empty)
            {
                MessageBox.Show("IP数据不能为空，请填写");
                return;
            }
            this.timer7.Enabled = true;
            this.timer7.Interval = 1000;
            this.timer7.Start();
            this.timer13.Enabled = true;
            this.timer13.Interval = 1000;
            this.timer13.Start();
            t3 = new Thread(SshCrack);
            t3.IsBackground = false;
            t3.Start();
        }
        public void SshCrack()
        {
            LogWarning10("创建时间：" + DateTime.Now + "   ------   " + "正在创建linux破解线程" + "\r\n");
            string password = @"password\linux.txt";
            button23.Enabled = false;
            button21.Enabled = true;
            label95.Text = "Y";
            label83.Text = "正在破解";
            using (StreamReader sr = new StreamReader(password, Encoding.Default))
            {
                string str = sr.ReadToEnd();
                if (!string.IsNullOrEmpty(str))
                {
                    string[] strs = str.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < strs.Length; i++)
                    {
                        try
                        {
                            System.Threading.Thread.Sleep(Convert.ToInt32(textBox40.Text));//访问延迟
                            string publicIP = textBox45.Text;//IP地址
                            int publicPort = Convert.ToInt32(textBox44.Text);//端口
                            string userName = textBox43.Text;//账号
                            string passwords = strs[i];//密码
                            string command = textBox2.Text;//执行命令的 附带
                            using (SshClient client = new SshClient(publicIP, publicPort, userName, passwords))
                            {
                                client.Connect();
                                var s2 = client.ToString();
                                SshCommand s3 = client.CreateCommand(s2);
                                TimeSpan s1 = new TimeSpan(Convert.ToInt32(textBox41.Text));
                                s3.CommandTimeout = s1;
                                var s4 = s3.ToString();
                                if (s4.Length >= 1)
                                {
                                    LogMessages11("创建时间：" + DateTime.Now + "   ------   " + "破解成功" + "   " + textBox45.Text + "  " + "账号：" + textBox43.Text + "   " + "密码：" + strs[i] + "\r\n");
                                    // strs i 指密码 | 28 账号 | 30 破解地址 | 29 端口 | 38 数据库
                                    this.timer13.Stop();
                                    this.timer13.Enabled = false;
                                    this.timer7.Enabled = false;
                                    this.timer7.Stop();
                                    label97.Text = "0";
                                    t3.Abort();
                                    label95.Text = "N";
                                    label83.Text = "破解成功";
                                    button23.Enabled = true;
                                    button21.Enabled = false;
                                    return;
                                }
                                else
                                {
                                    //内容过多展示的情况下界面会出现卡顿
                                    if (richTextBox12.Text.Length > 500000)
                                    {
                                        richTextBox12.Clear();
                                    }
                                    LogError12("创建时间：" + DateTime.Now + "   ------   " + "破解失败" + "   " + textBox45.Text + "  " + "账号：" + textBox43.Text + "   " + "密码：" + strs[i] + "\r\n");
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            //flag = false;
                            LogError12("创建时间：" + DateTime.Now + "   ------   " + "破解失败" + "   " + textBox45.Text + "  " + "账号：" + textBox43.Text + "   " + "密码：" + strs[i] + "\r\n");
                            Console.WriteLine(ex);
                            b5++;
                            label93.Text = b5.ToString();
                        }
                        m5++;
                        label99.Text = m5.ToString();
                    }
                    label97.Text = "0";
                    //t3.Abort();
                    this.timer7.Enabled = false;
                    this.timer7.Stop();
                    this.timer13.Stop();
                    this.timer13.Enabled = false;
                    label95.Text = "N";
                    label83.Text = "破解结束";
                    button23.Enabled = true;
                    button21.Enabled = false;
                }
            }
        }
        /// <summary>
        /// 对输出颜色进行封装 rictextbox12
        /// </summary>
        /// <param name="color"></param>
        /// <param name="text"></param>
        public delegate void LogAppendDelegate12(Color color, string text);
        public void LogAppend12(Color color, string text)
        {
            //richTextBox1.AppendText("\r\n");
            richTextBox12.SelectionColor = color;
            richTextBox12.AppendText(text);
        }
        /// red
        public void LogError12(string text)
        {
            LogAppendDelegate12 la = new LogAppendDelegate12(LogAppend12);
            richTextBox12.Invoke(la, Color.Red, text);
        }
        /// 警告
        public void LogWarning12(string text)
        {
            LogAppendDelegate12 la = new LogAppendDelegate12(LogAppend12);
            richTextBox12.Invoke(la, Color.Violet, text);
        }
        /// 绿色
        public void LogMessage12(string text)
        {
            LogAppendDelegate12 la = new LogAppendDelegate12(LogAppend12);
            richTextBox12.Invoke(la, Color.Green, text);
        }
        /// <summary>
        /// 对输出颜色进行封装 rictextbox11
        /// </summary>
        /// <param name="color"></param>
        /// <param name="text"></param>
        public delegate void LogAppendDelegate11(Color color, string text);
        public void LogAppend11(Color color, string text)
        {
            //richTextBox1.AppendText("\r\n");
            richTextBox11.SelectionColor = color;
            richTextBox11.AppendText(text);
        }
        /// 绿色
        public void LogMessages11(string text)
        {
            LogAppendDelegate11 la = new LogAppendDelegate11(LogAppend11);
            richTextBox11.Invoke(la, Color.Green, text);
        }

        private void button21_Click(object sender, EventArgs e)
        {
            if (t3 != null && t3.IsAlive)
            {
                t3.Abort();
                this.timer7.Enabled = false;
                this.timer7.Stop();
                this.timer13.Stop();
                label97.Text = "0";
                this.timer13.Enabled = false;
                label95.Text = "N";
                label83.Text = "破解结束";
                button23.Enabled = true;
                button21.Enabled = false;
                LogWarning12("创建时间：" + DateTime.Now + "   ------   " + "破解终止" + "\r\n");
            }
        }

        private void richTextBox12_TextChanged(object sender, EventArgs e)
        {
            //进行自动换行
            if (richTextBox12.Text.Length > 0)
            {
                richTextBox12.SelectionStart = richTextBox12.Text.Length;
                //richTextBox1.SelectionStart = Convert.ToInt32(richTextBox1.Text.Remove(richTextBox1.Text.Length - 1));
                richTextBox12.ScrollToCaret();
            }
        }

        private void timer7_Tick(object sender, EventArgs e)
        {
            Process myProcess = Process.GetCurrentProcess();//获取该进程
            ProcessThreadCollection PTC = myProcess.Threads;//获取其关联的线程，包括主线程
            int num = PTC.Count;//获取线程数量
            label97.Text = num.ToString();
        }

        private void button22_Click(object sender, EventArgs e)
        {
            try
            {
                System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.StartInfo.UseShellExecute = true;
                p.StartInfo.FileName = "password";
                p.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("打开错误" + ex);
            }
        }

        private void 帮助中心ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //帮助中心
            CrackHelp crack = new CrackHelp();
            crack.StartPosition = FormStartPosition.CenterScreen;
            crack.Show();
        }

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void timer8_Tick(object sender, EventArgs e)
        {
            MyCount += 1;
            this.label69.Text = MyCount.ToString().Trim();
        }

        private void timer9_Tick(object sender, EventArgs e)
        {
            MsCount += 1;
            this.label70.Text = MsCount.ToString().Trim();
        }

        private void timer10_Tick(object sender, EventArgs e)
        {
            OrCount += 1;
            this.label72.Text = OrCount.ToString().Trim();
        }

        private void timer11_Tick(object sender, EventArgs e)
        {
            PoCount += 1;
            this.label74.Text = PoCount.ToString().Trim();
        }

        private void timer12_Tick(object sender, EventArgs e)
        {
            MoCount += 1;
            this.label76.Text = MoCount.ToString().Trim();
        }

        private void timer13_Tick(object sender, EventArgs e)
        {
            LoCount += 1;
            this.label81.Text = LoCount.ToString().Trim();
        }
        /// <summary>
        /// FTP 破解
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button18_Click_1(object sender, EventArgs e)
        {
            richTextBox13.Clear();
            if (textBox36.Text == string.Empty)
            {
                MessageBox.Show("IP数据不能为空，请填写");
                return;
            }
            //获取线程的
            this.timer15.Enabled = true;
            this.timer15.Interval = 1000;
            this.timer15.Start();
            //用于计时的
            this.timer14.Enabled = true;
            this.timer14.Interval = 1000;
            this.timer14.Start();
            t4 = new Thread(FtpCrack);
            t4.IsBackground = false;
            t4.Start();
        }
        public void FtpCrack()
        {
            LogWarning13("创建时间：" + DateTime.Now + "   ------   " + "正在创建FTP服务破解线程" + "\r\n");
            string password = @"password\ftp.txt";
            button18.Enabled = false;
            button16.Enabled = true;//不禁止
            label117.Text = "Y";
            label102.Text = "正在破解";
            using (StreamReader sr = new StreamReader(password, Encoding.Default))
            {
                string str = sr.ReadToEnd();
                if (!string.IsNullOrEmpty(str))
                {
                    string[] strs = str.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < strs.Length; i++)
                    {
                        try
                        {
                            string FtpIp = textBox36.Text;
                            string UserName = textBox34.Text;
                            string Port = textBox35.Text;//端口
                            string PassWord = strs[i];//密码
                            FtpWebRequest ftprequest = (FtpWebRequest)WebRequest.Create(new Uri("ftp://" + textBox36.Text + ":" + textBox35.Text));
                            ftprequest.Credentials = new NetworkCredential(textBox34.Text, strs[i]);
                            ftprequest.Method = WebRequestMethods.Ftp.ListDirectory;
                            int swgf = Convert.ToInt32(textBox32.Text);//获取int类型格式
                            secrv = swgf / 1000;
                            ftprequest.Timeout = Convert.ToInt32(secrv);//32 int  默认超时连接5秒
                            FtpWebResponse ftpResponse = (FtpWebResponse)ftprequest.GetResponse();
                            var ftp = ftpResponse.ToString();
                            if (ftp.Length >= 1)
                            {
                                LogMessages14("创建时间：" + DateTime.Now + "   ------   " + "破解成功" + "   " + FtpIp + "  " + "账号：" + UserName + "   " + "密码：" + strs[i] + "\r\n");
                                // strs i 指密码 | 28 账号 | 30 破解地址 | 29 端口 | 38 数据库
                                //计时停止
                                this.timer14.Stop();
                                this.timer14.Enabled = false;
                                this.timer15.Enabled = false;
                                this.timer15.Stop();
                                t4.Abort();//终止线程
                                label119.Text = "0";
                                label117.Text = "N";
                                label102.Text = "破解成功";
                                button18.Enabled = true;
                                button16.Enabled = false;
                                return;
                            }
                            //else
                            //{
                            //    LogError13("创建时间：" + DateTime.Now + "   ------   " + "破解失败" + "   " + textBox36.Text + "  " + "账号：" + textBox34.Text + "   " + "密码：" + strs[i] + "\r\n");
                            //}
                        }
                        catch (Exception ex)
                        {
                            //内容过多展示的情况下界面会出现卡顿
                            if (richTextBox13.Text.Length > 500000)
                            {
                                richTextBox13.Clear();
                            }
                            LogError13("创建时间：" + DateTime.Now + "   ------   " + "破解失败" + "   " + textBox36.Text + "  " + "账号：" + textBox34.Text + "   " + "密码：" + strs[i] + "\r\n");
                            Console.WriteLine(ex);
                            b6++;
                            label115.Text = b6.ToString();
                        }
                        m6++;
                        label121.Text = m6.ToString();
                    }
                    //t4.Abort();//终止线程
                    label119.Text = "0";
                    this.timer14.Stop();
                    this.timer14.Enabled = false;
                    //线程也停止
                    this.timer15.Enabled = false;
                    this.timer15.Stop();
                    label117.Text = "N";
                    label102.Text = "破解结束";
                    button18.Enabled = true;
                    button16.Enabled = false;
                }
            }
        }

        private void timer14_Tick(object sender, EventArgs e)
        {
            FtCount += 1;
            this.label112.Text = FtCount.ToString().Trim();
        }

        private void richTextBox13_TextChanged(object sender, EventArgs e)
        {
            //进行自动换行
            if (richTextBox13.Text.Length > 0)
            {
                richTextBox13.SelectionStart = richTextBox13.Text.Length;
                //richTextBox1.SelectionStart = Convert.ToInt32(richTextBox1.Text.Remove(richTextBox1.Text.Length - 1));
                richTextBox13.ScrollToCaret();
            }
        }

        private void timer15_Tick(object sender, EventArgs e)
        {
            Process myProcess = Process.GetCurrentProcess();//获取该进程
            ProcessThreadCollection PTC = myProcess.Threads;//获取其关联的线程，包括主线程
            int num = PTC.Count;//获取线程数量
            label119.Text = num.ToString();
        }
        /// <summary>
        /// 对输出颜色进行封装 rictextbox13
        /// </summary>
        /// <param name="color"></param>
        /// <param name="text"></param>
        public delegate void LogAppendDelegate13(Color color, string text);
        public void LogAppend13(Color color, string text)
        {
            //richTextBox1.AppendText("\r\n");
            richTextBox13.SelectionColor = color;
            richTextBox13.AppendText(text);
        }
        /// red
        public void LogError13(string text)
        {
            LogAppendDelegate13 la = new LogAppendDelegate13(LogAppend13);
            richTextBox13.Invoke(la, Color.Red, text);
        }
        /// 警告
        public void LogWarning13(string text)
        {
            LogAppendDelegate13 la = new LogAppendDelegate13(LogAppend13);
            richTextBox13.Invoke(la, Color.Violet, text);
        }
        /// 绿色
        public void LogMessage13(string text)
        {
            LogAppendDelegate13 la = new LogAppendDelegate13(LogAppend13);
            richTextBox13.Invoke(la, Color.Green, text);
        }
        /// <summary>
        /// 对输出颜色进行封装 rictextbox14
        /// </summary>
        /// <param name="color"></param>
        /// <param name="text"></param>
        public delegate void LogAppendDelegate14(Color color, string text);
        public void LogAppend14(Color color, string text)
        {
            //richTextBox1.AppendText("\r\n");
            richTextBox14.SelectionColor = color;
            richTextBox14.AppendText(text);
        }
        /// 绿色
        public void LogMessages14(string text)
        {
            LogAppendDelegate14 la = new LogAppendDelegate14(LogAppend14);
            richTextBox14.Invoke(la, Color.Green, text);
        }

        private void button16_Click(object sender, EventArgs e)
        {
            if (t4 != null && t4.IsAlive)
            {
                t4.Abort();
                this.timer14.Stop();
                this.timer14.Enabled = false;
                //线程也停止
                this.timer15.Enabled = false;
                this.timer15.Stop();
                label117.Text = "N";
                label102.Text = "破解结束";
                button18.Enabled = true;
                button16.Enabled = false;
                label119.Text = "0";
                LogWarning13("创建时间：" + DateTime.Now + "   ------   " + "破解终止" + "\r\n");
            }
        }

        private void button17_Click(object sender, EventArgs e)
        {
            try
            {
                System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.StartInfo.UseShellExecute = true;
                p.StartInfo.FileName = "password";
                p.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("打开错误" + ex);
            }
        }

        private void 端口验证ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //打开端口验证
            Form2 s1 = new Form2();
            s1.StartPosition = FormStartPosition.CenterScreen;
            s1.ShowDialog();
        }
    }
}
